package com.vertx.core.tcp;

import io.vertx.core.Vertx;
import io.vertx.core.net.NetClient;
import io.vertx.core.net.NetClientOptions;
import io.vertx.core.net.NetServerOptions;

import java.util.concurrent.TimeUnit;

/**
 * @version v1.0
 * @Description: TODO(一句话描述该类的功能)
 * @Author: TongRui乀
 * @Date: 2021/5/10 6:28 下午
 */
public class VertxNetClient {

    public static void main(String[] args) {

        var options = new NetClientOptions();

        options.setIdleTimeout(1000);
        options.setIdleTimeoutUnit(TimeUnit.MILLISECONDS);
        options.setLogActivity(true);

        NetClient client = Vertx.vertx().createNetClient(options);

        client.connect(10086, "localhost", res->{
            if (res.succeeded()) {
                var socket = res.result();
                socket.write("hello server");
            }
        });
    }

}
